Deps { edges: self.graph.edges(pkg), resolve: self }
}
- pub fn deps_sorted(&self, pkg: &PackageId) -> Vec<&PackageId> {
- let mut deps = self.deps(pkg).collect::<Vec<_>>();
- deps.sort();
- deps
- }
-
pub fn deps_not_replaced(&self, pkg: &PackageId) -> DepsNotReplaced {
DepsNotReplaced { edges: self.graph.edges(pkg) }
}
}
let id = unit.pkg.package_id();
- let deps = self.resolve.deps_sorted(id);
- let mut ret = deps.iter().filter(|dep| {
+ let deps = self.resolve.deps(id);
+ let mut ret = deps.filter(|dep| {
unit.pkg.dependencies().iter().filter(|d| {
d.name() == dep.name() && d.version_req().matches(dep.version())
}).any(|d| {
/// Returns the dependencies necessary to document a package
fn doc_deps(&self, unit: &Unit<'a>) -> CargoResult<Vec<Unit<'a>>> {
- let deps = self.resolve.deps_sorted(unit.pkg.package_id());
- let deps = deps.iter().filter(|dep| {
+ let deps = self.resolve.deps(unit.pkg.package_id()).filter(|dep| {
unit.pkg.dependencies().iter().filter(|d| {
d.name() == dep.name()
}).any(|dep| {
if !unit.target.is_custom_build() && unit.pkg.has_custom_build() {
add_to_link(&mut ret, unit.pkg.package_id(), unit.kind);
}
- for unit in cx.dep_targets(unit)?.iter() {
+
+ // We want to invoke the compiler deterministically to be cache-friendly
+ // to rustc invocation caching schemes, so be sure to generate the same
+ // set of build script dependency orderings via sorting the targets that
+ // come out of the `Context`.
+ let mut targets = cx.dep_targets(unit)?;
+ targets.sort_by_key(|u| u.pkg.package_id());
+
+ for unit in targets.iter() {
let dep_scripts = build(out, cx, unit)?;
if unit.target.for_host() {
cmd.arg("--cfg").arg("test");
}
+ // We ideally want deterministic invocations of rustc to ensure that
+ // rustc-caching strategies like sccache are able to cache more, so sort the
+ // feature list here.
for feat in cx.resolve.features_sorted(unit.pkg.package_id()) {
cmd.arg("--cfg").arg(&format!("feature=\"{}\"", feat));
}
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0)
- .with_stderr("\
-[UPDATING] [..]
-[DOWNLOADING] [..]
-[DOWNLOADING] [..]
-[DOWNLOADING] [..]
-[DOWNLOADING] [..]
-[COMPILING] [..]
-[COMPILING] [..]
-[COMPILING] [..]
-[COMPILING] [..]
-[RUNNING] [..]
-[RUNNING] [..]
-[RUNNING] [..]
-[RUNNING] [..]
-[RUNNING] [..]
-[RUNNING] [..]
-[RUNNING] [..]
-[RUNNING] [..]
-[RUNNING] [..]
-[RUNNING] [..]
-[RUNNING] [..]
-[RUNNING] [..]
-[COMPILING] foo v0.1.0 [..]
+ .with_stderr_contains("\
[RUNNING] `rustc --crate-name foo [..] -L native=test1 -L native=test2 \
-L native=test3 -L native=test4`
-[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]"));
+"));
}
[RUNNING] [..]
[RUNNING] [..]
[RUNNING] `rustc --crate-name foo [..] \
---cfg 'feature=\"default\"' --cfg 'feature=\"f_a\"' --cfg 'feature=\"f_b\"' \
---cfg 'feature=\"f_c\"' --cfg 'feature=\"f_d\"' [..] \
+--cfg[..]default[..]--cfg[..]f_a[..]--cfg[..]f_b[..]\
+--cfg[..]f_c[..]--cfg[..]f_d[..] \
--cfg cfg_a --cfg cfg_b --cfg cfg_c --cfg cfg_d --cfg cfg_e`
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]"));
}